package com.fafa.File.Buffered;

import org.junit.Test;

import java.io.*;

public class Buffered_Copy {
    public static void main(String[] args) {

    }

    //移除警告
    @SuppressWarnings("all")
    @Test
    public void CopyFile() throws IOException {
        String readfile = "E:\\image\\1.png";
        String writefile = "E:\\2.png";


        BufferedInputStream br = new BufferedInputStream(new FileInputStream(readfile));
        BufferedOutputStream bw = new BufferedOutputStream(new FileOutputStream(writefile));

        int len;
        byte [] chars = new byte[1024];
        while((len = br.read(chars)) != -1) {
            bw.write(chars,0,len);
        }

        bw.close();
        br.close();
    }
}
